Using spectral and temporal filters with EEG signal to predict the temporal lobe epilepsy outcome after antiseizure medication via machine learning

Epilepsy is a neurological disorder in which the brain is transiently altered. Predicting outcomes in epilepsy is essential for providing feedback that can foster improved outcomes in the future. This study aimed to investigate whether applying spectral and temporal filters to resting-state electroencephalography (EEG) signals could improve the prediction of outcomes for patients taking antiseizure medication to treat temporal lobe epilepsy (TLE). We collected EEG data from a total of 46 patients (divided into a seizure-free group (SF, n = 22) and a non-seizure-free group (NSF, n = 24)) with TLE and retrospectively reviewed their clinical data. We segmented spectral and temporal ranges with various time-domain features (Hjorth parameters, statistical parameters, energy, zero-crossing rate, inter-channel correlation, inter-channel phase locking value and spectral information derived from Fourier transform, Stockwell transform, and wavelet transform) and compared their performance by applying an optimal frequency strategy, an optimal duration strategy, and a combination strategy. For all time-domain features, the optimal frequency and time combination strategy showed the highest performance in distinguishing SF patients from NSF patients (area under the curve (AUC) = 0.790 ± 0.159). Furthermore, optimal performance was achieved by utilizing a feature vector derived from statistical parameters within the 39- to 41-Hz frequency band with a window length of 210 s, as evidenced by an AUC of 0.748. By identifying the optimal parameters, we improved the performance of the prediction model. These parameters can serve as standard parameters for predicting outcomes based on resting-state EEG signals.

The classification performance of each time-domain feature under the OFTS strategy is presented in Table 1.Feature group F yielded the best AUC (0.838 ± 0.204), and Feature group B yielded the best accuracy (ACC; 0.824 ± 0.135), as shown in Table 1.Since Feature group B showed the highest performance on all metrics except for the AUC, Feature group B was evaluated with various ML classifiers.In this experiment, XGB showed the highest performance (AUC: 0.765 ± 0.179, ACC: 0.827 ± 0.112) on all metrics except for the true negative rate (TNR), positive predictive value (PPV), and negative predictive value (NPV).Detailed information about these analyses is provided in Supplementary Table 1.

Comparison of the major feature values between SF and NSF patients
Figure 2A shows topology plots demonstrating the ability of Feature group B (statistical parameters) to distinguish between the SF and NSF groups.The kurtosis and maximum value were extracted from the EEG signals of all TLE patients (SF group: 22 patients, NSF group: 24 patients), and the EEG channel-wise average of patients was used to obtain the kurtosis and maximum value.Among the statistical parameters for Feature group B, the kurtosis and maximum value were selected since the values showed significant differences between the SF and NSF groups ( p kurtosis = 0.002 , Cliff ′ sdelta Kurtosis = 0.576 , p max < 0.001, Cliff ′ sdelta max = 0.570 ) (Fig. 2B, C).The patterns of the topology plots were compared quantitatively using cosine similarity (CS) 30 and Euclidean distance (ED) 31 .For kurtosis, compared with NS, the OTS strategy showed a slight increase in CS ( CS OTS−NS = 0.013 ) and ED ( ED OTS−NS = 0.342 ), but the OFS strategy showed an increase in CS ( CS OFS−NS = 0.169 ) and a decrease in ED ( ED OFS−NS = − 0.023 ).The OFTS strategy yielded the highest ED (4.929), with a CS (0.936) close to 1.At the maximum value, all strategies yielded CS values close to 1. Furthermore, ED was lower under the OTS strategy ( ED OTS−NS = − 0.212 ) and higher under the OFS strategy ( ED OFS−NS = 2.199 ) than under NS.The OFTS strategy yielded the highest ED (5.935), similar to the findings for kurtosis (Supplementary Table 2).

Optimal EEG window length and optimal frequency band of the EEG signals for SF prediction
Figure 3A and B show the variance in predictive performance based on the window length of the resting-state EEG signal (average AUC of the four features at each window length is shown in Fig. 3A, the AUC of Feature group B at each window length is shown in Fig. 3B).As shown in Fig. 3A, the highest AUC of the four features at each window length was observed at 210 s (0.673 ± 0.076); this value was significantly different from that at other window lengths except 120, 150, 180, 240, and 270 s.As shown in Fig. 3B, the highest AUC of Feature group B at each window length was observed at 150 s (0.838 ± 0.102); this value was significantly different from that at almost  all other window lengths.Detailed information regarding these analyses is shown in Supplementary Table 3.
Figure 3C shows the AUC of each frequency band at the optimal EEG window length for Feature 2. The highest AUC in the low gamma band (frequency band of 39-41 Hz) was 0.748 ± 0.163, and the AUC showed a tendency to increase from the low-frequency band to the high-frequency band.In particular, it was found that the high

Discussion
In this study, we showed the effects of using spectral and temporal filters on the prediction of outcomes among patients with TLE.Our main findings are as follows.
(1) When predicting the outcome of TLE patients using resting-state EEG signals, simultaneously optimizing the spectral and temporal ranges greatly improved performance.
(2) When the EEG window length is greater than 2 min, using the gamma band and statistical parameters (especially the kurtosis and the maximum value) as features had a substantial impact on the prediction performance.

Synergy of spectral and temporal filters
We evaluated the use of each analysis strategy to compare and investigate the effect of spectral and temporal filters on prediction performance.When only one filter (spectral or temporal) was optimized, the performance was increased compared to the scenario in which no filer is optimized; however, the performance was further improved when both filters were optimized (Fig. 1).These results suggest that spectral and temporal filters must be used together to achieve a significant increase in performance, especially when using long-term EEG signals such as resting-state EEG.Additionally, we quantitatively compared the topology plot of each analysis strategy in terms of CS and ED, which represent the similarity of spatial patterns and the difference between the patterns, respectively.When the spectral filter was optimized, the CS between the two groups (SF and NSF) increased, which means that these groups had similar spatial patterns.The temporal filter seemed to be related to ED, indicating an increase in the intensity of the patterns; ED increased substantially when the spectral filter was applied.These results also show that synergy in the similarities of spatial patterns (CS and ED) occurs when the spectral and temporal filters are optimized simultaneously (Supplementary Table 2).

Appropriate optimal EEG window length and EEG frequency band for SF prediction
As shown in Fig. 3A and B, we found that increasing the window length of the resting-state EEG signals to greater than 2 min led to a significant improvement in performance.We believe that the discriminative power of features could (1) exist in a specific section of the EEG signals or (2) occur over a specific length of EEG signals (or both).
As resting-state EEG involves no specific stimulus or action 32 , it is expected that the discriminative power of features would occur over a specific length of time rather than in a specific section.
As shown in Fig. 3C, we compared the SF prediction performances within narrow frequency bands.The use of the low gamma band (30-50 Hz) with Feature 2 (statistical parameters) led to a higher predictive value.Strengthening or weakening of cognitive function is one of the side effects of ASM treatment, which is secondary to the intended purpose of seizure control [33][34][35] .Although it is well known that long-term treatment with ASMs can adversely affect cognitive functions, such as attention, vigilance, and psychomotor speed 36,37 , some ASMs (e.g., carbamazepine, lamotrigine, valproate) have positive psychotropic effects 38 .
EEG modulation in the gamma band (> 30 Hz), has been shown to be correlated with large-scale brain network activity 39 .In particular, modulation in this band is known to play a crucial role in cognitive processes (e.g., working memory, attention, and perceptual grouping) and is thus assumed to reflect the consciousness level 40,41 .
Additionally, the EEG modulation in the gamma band was reflected in the kurtosis and the maximum value.One phenomenon-namely, sharp wave ripples-may account for the processes assessed by kurtosis and maximum values.Sharp wave ripples, which support the consolidation of recently acquired memories or the planning of future actions, consist of several spectral components: a slow sharp wave (5-15 Hz), a high-frequency "ripple" oscillation (150-200 Hz), and a slow "gamma" oscillation (20-40 Hz).The fusion of sharp wave ripples could also be reflected as increased power in the slow gamma band 42 .These prior findings lend credibility to our results with respect to the importance of low gamma and Feature 2.

Limitations and future work
Our study has several limitations.First, our analysis was based on individual EEG segments for each patient.We only drew segments once for all window lengths because we were comparing performance across window lengths, and thus, we suspected that having different numbers of epochs for different window lengths might affect the results.The use of only one segment per patient might not fully capture the variability inherent in EEG signals.This approach may limit the generalizability of our findings, as multiple segments could provide a more comprehensive view of each patient's EEG characteristics.Second, the highest frequency bands that can be observed through scalp EEG signals are only approximately 50 Hz 43 .Therefore, it is necessary to investigate frequency ranges higher than 50 Hz through another modality through an additional method.Third, most patients were already taking ASMs at the time of the EEG study.Fourth, because the dataset used in this study consisted of patients receiving mono-or polytherapy, it is difficult to characterize the effect of a particular ASM on the EEG signal.Finally, this retrospective study was conducted using a limited dataset, which could introduce bias in the characteristics of epilepsy patients.Future research should apply more sophisticated methods that can aggregate multiple frequency bands and multiple time segments using resting-state EEG signals.

Conclusion
This study shows that the application of spectral and temporal filters to resting-state EEG signals enhanced the prediction of long-term patient outcomes when the spectral and temporal filters were simultaneously optimized.In particular, an EEG window length of greater than 2 min and the gamma band substantially impacted the prediction performance.This optimization strategy can be applied for the early identification of patients with drug-resistant epilepsy, as they are potential candidates for nonpharmacologic intervention.

Patients and data collection
We retrospectively analyzed the medical records and EEG data of patients with TLE who visited Seoul National University Hospital between 2014 and 2021.All included patients had experienced at least one clinical seizure and were confirmed as having TLE based on seizure semiology, EEG, and/or 3.0-Tesla magnetic resonance imaging throughout the follow-up period.All patients received ASM during the follow-up period.We included patients whose initial EEG data were obtained using the NicoletOne® EEG system (Natus, San Carlo, CA, USA).Demographic and clinical characteristics, including baseline and final seizure frequencies, were obtained through a retrospective review of medical records.A total of 46 patients with TLE were selected and divided into two groups according to the final outcome: the SF group (seizure-free for the last year of follow-up, n = 22) and the NSF group (at least one seizure in the last year of follow-up, n = 24).In our capacity as a tertiary referral hospital, we identified only one treatment-naïve patient with TLE, while all other patients were already using ASMs at the time of EEG study.None of the patients had undergone ketogenic diet therapy.This study was conducted in accordance with the Declaration of Helsinki.This study was approved by the Institutional Review Board of Seoul National University Hospital (IRB No. H-2109-005-1251), and the need for informed consent was waived by the Institutional Review Board of Seoul National University Hospital due to the retrospective nature of the study.Detailed patient information can be found in Table 2.

Preprocessing
The resting-state EEG signals, recorded from 20 to 320 s, were epoched and then scaled by 10 6 to convert the measurements from volts to microvolts (µV), thus enhancing both the relevance and clarity of the data 44 .Data www.nature.com/scientificreports/from all 21 channels were used in further analysis.However, data referencing was conducted only with the following EEG channels: F3, Fz, F4, C3, Cz, C4, P3, Pz, P4, O1, and O2 45 .

Analysis strategy
To determine the effect of appropriate spectral and temporal ranges in predicting SF outcomes of TLE patients, the following three strategies were compared.(1) In the OTS strategy, a grid search was applied to optimize the temporal range of the EEG signals in a fixed frequency band (0.1-51 Hz).The temporal segments were extracted only once with different durations.All segments started precisely at the 0-s mark of the resting-state EEG data.The target temporal range was set at 1-s intervals from 1 to 30 s and 30-s intervals from 30 to 300 s (thus yielding a total of 39 temporal segments, 1, 2, 3, …, 27, 28, 29, 30, 60, …, 90, 120, 150, …, 300 s).(2) In the OFS strategy, a grid search was applied to optimize the spectral range of EEG signals from 0.1 Hz (low cut) to 2 Hz (high cut) up to 49 Hz (low cut) to 51 Hz (high cut) (a total of 50 bands spanning 2 Hz) for the total resting state (300 s).
(3) In the OFTS strategy, a two-grid search was applied to 50 spectral and 39 temporal ranges to optimize the spectral and temporal ranges simultaneously.Then, bandpass filtering, standardization 46 and segmentation were sequentially performed.Figure 4 shows the analysis pipeline for OFTS.In the case of NS, total resting state (300 s) and fixed-frequency bandpass cutoff from 0.1 Hz (low cut) to 51 Hz (high cut) were applied.

Feature extraction
Among the many EEG features, four types of features were selected based on the following three questions (1) Is it a time-domain feature?(The analysis pipeline included a narrow bandpass filter).
(2) Has it ever been used in an EEG-based epilepsy study?(3) What is the computational cost?(Supplementary  Many studies have used energy as an indicator of brain activity 18,19 .Therefore, the linear and nonlinear energy of the EEG signals were included in Feature group C 52 .A total of 42 energy parameters were acquired using Eqs.( 10), (11) and used as ML inputs.

Zero-crossing rate (Feature group D)
The zero-crossing rate is the rate at which a signal changes from positive to zero to negative or from negative to zero to positive 53 .This parameter has been used to detect or classify seizures from normal EEG signals in many studies 54,55 .In this study, the zero-crossing rate and its first derivative were included in Feature group D 52 .A total of 42 zero-crossing parameters were acquired using Eqs.( 12), ( 13) and used as ML inputs.

ICC (Feature group E)
In the context of EEG analysis, cross-correlation is a powerful tool 56,57 that offers unique insights into the functional connectivity and relationships between different brain regions.We used the Pearson correlation coefficient as the correlation coefficient in Eq. ( 14), which is a measure of the linear correlation between two variables X and Y.A total of 210 ICC were acquired using Eq. ( 14) and 20 graph measurements 23,58 were used as ML inputs.Graph measurements were performed using NetworkX 59 and nilearn 60 Python libraries.

ICPLV (Feature group F)
In the context of EEG analysis, ICPLV is a powerful tool for investigating phase synchronization between brain regions.Its ability to provide insights into the timing and coordination of brain activities makes it invaluable in both research and clinical settings 61,62 .A total of 210 ICPLVs were acquired using Eq. ( 15), and 20 graph measurements 23,58 were used as ML inputs.

Spectral parameters (Feature group G)
Spectral power and phase, which are acquired using fast Fourier transform (FFT) (Eq.16), are crucial components of EEG signal analysis, These parameters provide deep insights into brain function and neural activity. 63,64e extracted five spectral parameters: mean, median, minimum, maximum, skewness and standard deviation of power and phase.A total of 126 spectral parameters were acquired using Eq. ( 16) and used as ML inputs.

Figure 1 .
Figure 1.Comparative Analysis of AUC Values Across Different Analysis Strategies and Features.(A) Boxplot representation showing the aggregate AUC values for each analysis strategy.This part of the figure combines results from distinct nine feature groups, with each strategy displaying 45 data points.These points represent the AUC values obtained from fivefold cross-validation for each of the feature groups, thereby illustrating the collective performance across multiple validation scenarios.(B) Bar charts depicting the AUC values for each individual feature under the different analysis strategies.The chart provides a feature-specific comparison, illustrating how each feature group contributes to the overall efficacy of the strategies.

Figure 2 .
Figure 2. (A) Topology plots for each analysis strategy using the kurtosis and maximum value of Feature 2. Each topology plot consisted of the average value of each group (seizure-free (SF) or non-seizure-free (NSF)).(B, C) Comparison of SF vs. NSF groups according to the kurtosis (B) and the maximum value (C) under OFTS for each patient.For each patient's kurtosis and maximum values in (B, C), the average for all EEG channels was used.Asterisks indicate that the p value is less than 0.05.

Figure 3 .
Figure 3. (A) Average performance (AUC) for all feature groups with each EEG window length on the optimal frequency band.Asterisks indicate that the p value is lower than 0.05 compared with the AUC at 270 s.(B) Performance (AUC) of Feature 2 on the optimal frequency band at each EEG window length.Asterisks indicate that the p value is lower than 0.05 compared with the AUC at 150 s. (C) Performance (AUC) of Feature 2 at the optimal EEG window length for each frequency band.The frequency range of each band is as follows: delta band, 0.1-4 Hz; theta band, 4-8 Hz; alpha band, 8-12 Hz; beta1 (low beta) band, 12-16 Hz; beta2 (beta) band, 16-20 Hz; beta3 (high beta) band, 20-30 Hz; and low gamma band, 30-50 Hz.The asterisk indicates the frequency band with the highest performance. https://doi.org/10.1038/s41598-023-49255-2

Table 1 .
The classification performance of each time-domain feature under the optimal frequency and time strategy.Significant values are in[bold].The optimal frequency band and window length for each feature were as follows.Values in bold represent the best results within each column.

Table 2 .
Demographic and clinical characteristics of the seizure-free and non-seizure-free groups.EEG, electroencephalography; SD, standard deviation; IED, interictal epileptic discharge; ASM, antiseizure medication; CNS, central nervous system.a Chi-square test.b Cramer's V. c Student 's t test.d Cohen's d. e Mann-Whitney U test.f Mann-Whitney effect size r.g Fisher's exact test.